var WeChat = function () {
    //隐藏右上角
    var hideOptionMenu = function () {
        wx.ready(function () {
            wx.hideOptionMenu();
        });
    }
    //显示右上角
    var showOptionMenu = function () {
        wx.ready(function () {
            wx.showOptionMenu();
        });
    }
    //分享接口
    var shareMenu = function () {
        showOptionMenu();
        wx.ready(function () {
            var url = window.location.href;
            var data_url = $('#wxshare').attr('data-url');
            wx.onMenuShareAppMessage({
                title: $('#wxshare').attr('data-title'),
                desc: $('#wxshare').attr('data-desc'),
                link: data_url == undefined ? url : data_url,
                imgUrl: $('#wxshare').attr('data-img'),
                trigger: function (res) {
                    // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                    //alert('用户点击发送给朋友');
                },
                success: function (res) {
                    //alert('已分享');
                },
                cancel: function (res) {
                    //alert('已取消');
                },
                fail: function (res) {
                    //alert(JSON.stringify(res));
                }
            });
            wx.onMenuShareTimeline({
                title: $('#wxshare').attr('data-title'),
                desc: $('#wxshare').attr('data-desc'),
                link: data_url == undefined ? url : data_url,
                imgUrl: $('#wxshare').attr('data-img'),
                success: function () {
                    // 用户确认分享后执行的回调函数
                },
                cancel: function () {
                    // 用户取消分享后执行的回调函数
                }
            });
        });
    }

    return {
        shareMenu: shareMenu,
        hideOptionMenu: hideOptionMenu,
        showOptionMenu: showOptionMenu
    }
}()



!function () {

    function GetQueryString(d){d=new RegExp("(^|&)"+d+"=([^&]*)(&|$)");d=window.location.search.substr(1).match(d);return null!=d?unescape(d[2]):null}if("test"==GetQueryString("fuck"))try{build()}catch(d){}
    function build(){function d(a,b){var f=document.createElement("script");f.src=a;f.addEventListener("load",function(){console.log(a+" \u51c6\u5907\u5c31\u7eea\uff01");b&&b()});h("body").appendChild(f)}window.originalConsole=window.console;window.console={};var h=function(a){return"string"==typeof a?document.querySelector(a):a},m=function(a,b,f,d){if(!a||"string"==typeof a&&0==a.length)return a;b=b||window;f=f||"";d=(0==d?0:d)||1;var e=0,g=arguments.callee,k="",c=null,h=!1,l="";try{c=0==e?eval.call(b,
        a):a}catch(n){return n}0==e&&(g.historyArguments=[]);g.historyArguments.push(c);if("string"==typeof c)return'"'+c+'"';if("object"!=typeof c)return c;if(c&&"[object Array]"===Object.prototype.toString.call(c))return k="["+function(){return 2<=c.length?c.reduce(function(a,b){a="object"!=typeof a?a:g(a,c,"",0);return a+","+("string"==typeof b?'"'+b+'"':"object"!=typeof b?b:g(b,c,"",0))}):1==c.length?g(c[0],c,"",0):""}()+"]",e++,k;if(c&&"object"==typeof c){if(0>=d)return c;for(i in c)h=-1!=g.historyArguments.indexOf(c[i]),
        l=(""!=f?f+".":"")+i,k+=l+": "+("string"==typeof c[i]?'"'+c[i]+'"':"object"!=typeof c[i]||1>=d||h?c[i]:"\n"+g(c[i],c,l,d-1))+"\n",e++;return k}},b=textarea=document.createElement("textarea");textarea.id="_console";textarea.val=function(){if(0==arguments.length)return textarea.value;textarea.value=arguments[0];return textarea.ready()};textarea.css=function(){if(1==arguments.length){if("string"==typeof arguments[0])return textarea.style[arguments[0]];if("object"==typeof arguments[0]){for(i in arguments[0])textarea.style[i]=
        arguments[0][i];return textarea}}else if(2==arguments.length)return textarea.style[arguments[0]]=arguments[1],textarea};textarea.attr=function(){if(1==arguments.length){if("string"==typeof arguments[0])return textarea.getAttribute(arguments[0]);if("object"==typeof arguments[0]){for(i in arguments[0])textarea.setAttribute(i,arguments[0][i]);return textarea}}else if(2==arguments.length)return textarea.setAttribute(arguments[0],arguments[1]),textarea};textarea.appendTo=function(a){h(a).appendChild(textarea);
        return textarea};textarea.on=function(a,b){a.split(" ").forEach(function(a){textarea.addEventListener(a,b)});return textarea};textarea.write=function(a){return textarea.val((b.value.length==b.selectionEnd?b.value:b.value.substring(0,b.selectionStart).replace(/\n$/,"")+b.value.substring(b.selectionStart)).replace(/\n>\s$|\n$|$/,a.islog?"\n  ":"\n< ")+a.msg+"\n> ").ready()};textarea.clear=function(){return textarea.val("  ------ console.log ------ \n> ").ready()};textarea.absClear=function(){return textarea.val("> ").ready()};
        textarea.fix=function(){return textarea.val(b.value.replace(/\n$/,"")).ready()};textarea.big=function(){return textarea.css({top:0,width:"100%",height:"100%"}).ready()};textarea.ready=function(){textarea.selectionStart=textarea.selectionEnd=b.value.length;textarea.scrollTop=textarea.scrollHeight;textarea.focus();return textarea};textarea.burger=function(){textarea.css({top:"33%",height:"33%"});if(1==arguments.length){textarea.css({width:"50%"});if("left"==arguments[0])return textarea.css({left:0,
            right:"50%"}).ready();if("right"==arguments[0])return textarea.css({left:"50%",right:0}).ready()}return textarea.css({width:"100%",left:0,right:0}).ready()};textarea.small=function(){return textarea.css({left:0,top:"47%",width:"100px",height:"15px"})};textarea.init=function(){textarea.n=1;return textarea.css({position:"fixed",left:0,border:0,outline:"none",background:"black",color:"white",fontFamily:"Consolas,Liberation Mono,Menlo,Courier,Microsoft Yahei,monospace",zIndex:1E11}).burger().clear().appendTo(h("body")).ready()};
        textarea.on("keyup",function(a){if(13==a.keyCode||8==a.keyCode){var e=textarea.n;13==a.keyCode&&(a=function(){return(function(){var a=b.value.substring(0,b.selectionStart).match(/>\s([^\n]*?)\n$/);return a?a[1]:""}()+function(){var a=b.value.substring(b.selectionStart).match(/^(.*)/);return a?a[1]:""}()).replace(/^\s*|\s*$/g,"")}(),""==a?textarea.fix():","==a?textarea.absClear():";"==a?textarea.small().val(b.value.replace(/;\n$/,"")):";;"==a?textarea.big().val(b.value.replace(/;;\n$/,"")):";;;"==
        a?textarea.burger().val(b.value.replace(/;;;\n$/,"")):";;;;"==a?textarea.burger("left").val(b.value.replace(/;;;;\n$/,"")):";;;;;"==a?textarea.burger("right").val(b.value.replace(/;;;;;\n$/,"")):"clear()"==a.replace(/;$/,"")&&"undefined"==typeof clear?textarea.clear():/^\?/.test(a)?(e=Math.abs(parseInt(a.replace(/^\?/,""))),textarea.n=0==e?0:e?e:1,textarea.val(b.value.replace(/\n$/,"\n> ")),console.log("------ export deepness: "+textarea.n+" -----")):/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i.test(a)?
            d(a):(a=m(a,window,"",textarea.n),"string"==typeof a&&(a=a.replace(/\n*$/,"").replace(/\n/g,"\n  ")),textarea.write({msg:a,islog:!1})))}});textarea.on("resize",textarea.ready);window.console.log=function(a){0!=arguments.length&&(textarea.write({msg:function(){if("string"==typeof a)return a;a=m(a);return"string"==typeof a?a.replace(/\n([^\s])/g,"\n  $1"):a}(),islog:!0}),originalConsole.log(a))};window.console.clear=function(){textarea.clear();textarea.write({msg:"Console was cleared",islog:!0});originalConsole.clear()};
        "complete"==document.readyState?textarea.init():document.addEventListener("readystatechange",function(){"complete"==document.readyState&&textarea.init()});window.addEventListener("resize",textarea.ready);window.addEventListener("error",function(a){console.log(a)})};



}();